﻿using Core.Network;
using System;

namespace Core
{
    public class NetworkSystem : Component, IAwake
    {
        private TaskQueue<AbstractTask> queue;

        public void Awake()
        {
            queue = new TaskQueue<AbstractTask>(3);
        }

        public void Update()
        {
            queue.Update();
        }

        /// <summary>
        /// 加载到内存
        /// </summary>
        public void Load(string uri, Action<IWebTask> func)
        {
            var task = G.Factory.CreateInstance<WebRequestTask>();
            task.Awake(uri, func);
            queue.Add(task);
        }

        /// <summary>
        /// 下载到本地文件中
        /// </summary>
        public void Download()
        {
        }
    }
}
